package com.example.superoa.model.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONArray;
import com.example.superoa.model.dao.ContractDao;
import com.example.superoa.model.mappers.ContractMapper;
import com.example.superoa.model.pojos.Contract;
import com.example.superoa.model.vo.ContractVo;

@Service
@Transactional(rollbackFor=Exception.class)
public class ContractService {
	@Autowired
	private ContractMapper contractmapper;
	@Autowired
	private ContractDao contractdao;
	/*查询合同数据*/
	public List<ContractVo> contractAll(){
		return contractmapper.contractAll();
	}
	public JSONArray select() {
		return contractmapper.selectstaff();
	}
	
	/*获取编辑数据*/
	public Contract contreactById(int contreact_id) {
		return contractmapper.contreactById(contreact_id);
	}
	/*编辑确定*/
	public void contreactbj(Contract cc) {
		Contract c=contractdao.findById(cc.getContreact_id()).get();
		c.setEndDate(cc.getEndDate());
		c.setContract_TypeName(cc.getContract_TypeName());
		c.setStartDate(cc.getStartDate());
		c.setTryEndDate(cc.getStartDate());
		c.setContract_Desc(cc.getContract_Desc());
		c.setRemarks(cc.getRemarks());
	}
	/*条件查询*/
	public JSONArray contractselect(String contract_TypeName) {
		JSONArray array =contractmapper.contractselect(contract_TypeName);
		return array;
		
	}
	//签订合同
	public void Contractstate(String contreact_qdstate,int contreact_id) {
		System.out.println("contreact_id=="+contreact_id);
		System.out.println("Contreact_qdstate=="+contreact_qdstate);
		contractmapper.contractstate(contreact_qdstate, contreact_id);
	}
}
